{extend name="layout/main" /}

{block name="header"}

{/block}

{block name="content"}
<section class="panel">
    <header class="panel-heading">
        <h4>编辑公告</h4>
    </header>
    <div class="panel-body" style="padding-bottom: 50px">
        <form class="form-horizontal" method="post" onsubmit="return false" role="form">
            <div class="form-group">
                <label class="col-sm-2 control-label">标题</label>

                <div class="col-sm-5">
                    <input type="text"  value="{$info->title}" name="title" class="form-control"
                           placeholder="请输入客户用户名">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">内容</label>
                <div class="col-sm-5">
                    <input type="text" name="content" value="{$info->content}" class="form-control" placeholder="请输入客户登陆密码">
                </div>
            </div>
                        <div class="form-group">
                <label class="col-sm-2 control-label">状态</label>
                <div class="col-sm-5">
                    {if $info->status == 1}
                        <input type="radio" name="status" value="1" checked>启用
                        <input type="radio" name="status" value="0">禁用
                    {else/}
                        <input type="radio" name="status" value="1">启用
                        <input type="radio" name="status" value="0" checked>禁用
                    {/if}
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-offset-2 col-sm-10">
                    <button type="submit" data-url="{:url('admin/notice/update',['id'=>$info->id])}"
                            onclick="main.ajaxPosts(this)" class="btn btn-primary">确定修改
                    </button>
                </div>
            </div>
        </form>
    </div>
</section>
{/block}


{block name="footer"}
    <script src="/admin/vendor/fuelux/radio.js"></script>
    <script>
        function selectFile(e) {
            $(e).next().click();
        }

        function uploadImage(target) {
            var $this = $(target);
            var url = "{:url('upload/upload')}";
            var file = target.files[0];
            if (file.length == 0) {
                mui.alert('请选择需要上传的图片');
                return false;
            }
            var data = new FormData();
            data.append('image', file);
            $this.prev().html('上传中');
            $this.prev().attr('disabled',true);
            $.ajax({
                url: url,
                type: "POST",
                data: data,
                processData: false,  // 告诉jQuery不要去处理发送的数据
                contentType: false,   // 告诉jQuery不要去设置Content-Type请求头
                dataType: 'json',
                success: function (response) {
                    $this.prev().html('重新上传');
                    $this.prev().attr('disabled',false);
                    if (response.code == 0) {
                        $("#" + $this.attr('data-id')).attr('src',response.url);
                        $this.siblings('input').val(response.url)
                    } else {
                        main.waringAlert(response.message)
                    }
                }
            })
        }
    </script>
{/block}